

/****
 * 第一种惰性模式
****/
/*var A ={};
A.on = function(dom, type, fn){
	if(document.addEventListener){
		return function(dom, type, fn){
			dom.addEventListener(type, fn, false);
		}
	}else if(document.attachEvent){
		return function(dom, type, fn){
			dom.addEventListener('on' + type, fn);
		}
	}else{
		return function(dom, type, fn){
			dom['on' + type] = fn;
		}
	}
}();
console.log(A.on);
*/


/****
 * 第二种惰性模式
****/
/*var A ={};
A.on = function(dom, type, fn){
	if(dom.addEventListener){
		A.on = function(dom, type, fn){
			dom.addEventListener(type, fn, false);
		}
	}else if(dom.attachEvent){
		A.on = function(dom, type, fn){
			dom.addEventListener('on' + type, fn);
		}
	}else{
		A.on = function(dom, type, fn){
			dom['on' + type] = fn;
		}
	}
	A.on(dom, type, fn);
};
A.on(document.body, 'click', function(){
	alert(11);
})*/


/****
 第一种
****/
/*var createXHR = (function(){
	if(typeof XMLHttpRequest != "undefined"){
		return function(){
			return new XMLHttpRequest();
		};
	}else if(typeof ActiveXObject != "undefined"){
		return function(){
			if(typeof arguments.callee.activeXString != "string"){
				var versions = ["MSXML2.XMLHttp.6.0", "MSXML2.XMLHttp.3.0", "MSXML2.XMLHttp"],
						i = 0,
						len = versions.length;
						for(; i < len; i++){
							try{
								new ActiveXObject(versions[i]);
								arguments.callee.activeXString = varsions[i];
								break;
							}catch(ex){

							}
						}
						return new ActiveXObject(arguments.callee.activeXString);
			}else{
				throw new Error("您的浏览器并不支持Ajax");
			};
		}
	}
})
*/

/****
 第二种
****/
function createXHR(){
	if(typeof XMLHttpRequest != "undefined"){
		createXHR = function(){
			return new XMLHttpRequest();
		};
	}else if (typeof ActiveXObject != "undefined"){
		createXHR = function(){
			if(typeof arguments.callee.activeXString != "string"){
				var versions = ["MSXML2.XMLHttp.6.0", "MSXML2.XMLHttp.3.0", "MSXML2.XMLHttp"],
						i = 0,
						len = versions.length;
						for(; i < len; i++){
							try{
								new ActiveXObject(versions[i]);
								arguments.callee.activeXString = varsions[i];
								break;
							}catch(ex){

							}
						}
					}
						return new ActiveXObject(arguments.callee.activeXString);
					};
			}else{
				createXHR = function(){
				throw new Error("您的浏览器并不支持Ajax");
			};
		}
		return createXHR();
	}
